SYSTEM	= x86-64_sles9.0_3.3
LIBFORMAT	= static_pic

DRIVER          = driver
EXE		= $(DRIVER)
OBJ1		= $(DRIVER).o
SRC1		= $(DRIVER).c

FUNC            = stofac
OBJ2            = $(FUNC).o
SRC2 		= $(FUNC).c

CALLBACK        = bigmcallback
OBJ3            = $(CALLBACK).o
SRC3            = $(CALLBACK).c

CONCERTDIR	= /usr/local/ibm/ilog/cplex/concert25
CPLEXDIR     	= /usr/local/ibm/ilog/cplex/cplex121
CPLEXINCDIR  	= $(CPLEXDIR)/include
CONCERTINCDIR	= $(CONCERTDIR)/include
CPLEXLIBDIR  	= $(CPLEXDIR)/lib/$(SYSTEM)/$(LIBFORMAT)
CONCERTLIBDIR	= $(CONCERTDIR)/lib/$(SYSTEM)/$(LIBFORMAT)
CFLAGS  	= -Wall -g
INCFLAGS	= -m64 -c -O -fPIC -fexceptions -DNDEBUG -DIL_STD
LINFLAGS	= -m64 -O -fPIC -fexceptions -DNDEBUG -DIL_STD
CC 		= gcc
CPLEXLNFLAGS	= $(CPLEXLIBDIR) -lilocplex -lcplex -lpthread
CONCERTLNFLAGS	= $(CONCERTLIBDIR) -lconcert -lm -lpthread


all : $(EXE) 

clean : 
	rm *.o

$(EXE): $(OBJ1) $(OBJ2) $(OBJ3)
	$(CC) $(CFLAGS) $(LINFLAGS) -I$(CPLEXINCDIR) -I$(CONCERTINCDIR) $(OBJ1) $(OBJ2) $(OBJ3) -o $(EXE) -L$(CPLEXLNFLAGS) -L$(CONCERTLNFLAGS) -lRmath

$(OBJ1): $(SRC1)
	$(CC) $(CFLAGS) $(INCFLAGS) -I$(CPLEXINCDIR) -I$(CONCERTINCDIR) $(SRC1) -o $(OBJ1) 

$(OBJ2): $(SRC2)
	$(CC) $(CFLAGS) $(INCFLAGS) -I$(CPLEXINCDIR) -I$(CONCERTINCDIR) $(SRC2) -o $(OBJ2) 

$(OBJ3): $(SRC3)
	$(CC) $(CFLAGS) $(INCFLAGS) -I$(CPLEXINCDIR) -I$(CONCERTINCDIR) $(SRC3) -o $(OBJ3) 
